package com.usian.controller;

import com.usian.feign.UserFeign;
import com.usian.pojo.B.day14.Team;
import com.usian.pojo.day01.Member;
import com.usian.r.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author BYBL
 * @date 2023/8/22
 */
@RestController
public class UserController {

    @Autowired
    UserFeign userFeign;

    @RequestMapping("/member/login")
    public R login(@RequestBody Member user){
        try {
            R login = userFeign.login(user);
            return R.success(login.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    //竞赛页面中的战队查询所有
    @RequestMapping("/team/findAll")
    public R findAll(@RequestBody Team team){
        try {
            R all = userFeign.findAll(team);
            return R.success(all.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }
}
